package day03;
import java.util.Scanner;
//猜数字小游戏
public class Guessing {
    public static void main(String[] args) {
       /*
       Math.random()-------0.0到0.99999...
       *1000---------------0.0到999.999...
       +1------------------1.0到1.99999...
       （int)--------------1到1000，此步骤也可以在+1之前
        */
        int num = (int)(Math.random()*1000+1);
        Scanner scan =new Scanner(System.in);
        System.out.println("猜吧！");
        int guess = scan.nextInt();
        do{System.out.println("猜吧");
            if (guess>num) {//选择几路结构，要看有几种情况
                System.out.println("猜大了");
            }else {
                System.out.println("猜小了");
            }//放在循环变量变化之前
            guess = scan.nextInt();
        }
        while (guess==num);
        System.out.println("猜对了！");
        /*
        int num = 250;//目标数字
        Scanner scan =new Scanner(System.in);
        System.out.println("猜吧！");
        int guess = scan.nextInt();
        while (guess!=num){
            System.out.println("猜吧");
            if (guess>num) {//选择几路结构，要看有几种情况
                System.out.println("猜大了");
            }else {
                System.out.println("猜小了");
            }//放在循环变量变化之前
            guess = scan.nextInt();
        }
        System.out.println("猜对了！");
*/
    }
}
